import zlib


def byte_to_str(value):
    if isinstance(value, bytes):
        return str(value, encoding="utf-8")
    raise Exception("Type Error")


def str_to_byte(value):
    if isinstance(value, str):
        return bytes(value, encoding="utf-8")
    raise Exception("Type Error")


def compress_content(content):
    if isinstance(content, str):
        byte_content = str_to_byte(content)
        return zlib.compress(byte_content, 9)
    raise Exception("Type Error")


def decompress_content(content):
    if isinstance(content, bytes):
        byte_content = zlib.decompress(content)
        str_content = byte_to_str(byte_content)
        return str_content
    raise Exception("Type Error")
